﻿//using System;
//using System.Collections.Generic;
//using System.ComponentModel;
//using System.Data;
//using System.Drawing;

//using System.Text;
//using System.Windows.Forms;
//using Shprosses.Modelling.Components;
//using Shprosses.Render;
//using Shprosses.Info;
//using Shprosses.Calculations;
//using Shprosses;

//namespace Shprosses.Editor
//{
//    public partial class ModelComponents : Form
//    {
//        public static ModelComponents Create(ProfilesProviderDelegate profilesProviderDelegate, 
//                                             SimpleRender thumbnailRender, 
//                                             Size thumbnailSize)
//        {
//            ModelCoordinateConverter coordinateConverter = new ModelCoordinateConverter();
//            coordinateConverter.UseAutoScale = true;
//            ModelComponents modelComponents = new ModelComponents();
//            ImageList imageListConnectors = new ImageList();
//            imageListConnectors.ColorDepth = ColorDepth.Depth32Bit;
//            imageListConnectors.ImageSize = thumbnailSize;

//            ImageList imageListProfiles = new ImageList();
//            imageListProfiles.ColorDepth = ColorDepth.Depth32Bit;
//            imageListProfiles.ImageSize = thumbnailSize;
                        
//            ProfilesInfo info = profilesProviderDelegate.Invoke();


//            foreach (Shprosses.Modelling.Components.IComponent connector in info.Connectors)
//            {
                
//                //connector.MoveTo(new Shprosses.Modelling.ModelPoint(boundingBox.Width / 2, boundingBox.Height / 2));
//                connector.MoveToZeroPoint();
//                RectangleF boundingBox = connector.BoundingBox;
//                Graphics connectorsGraphics;
//                Image thumbnail = new Bitmap(thumbnailSize.Width, thumbnailSize.Height);
//                connectorsGraphics = Graphics.FromImage(thumbnail);
//                connectorsGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
//                connectorsGraphics.Clear(Color.White);
//                thumbnailRender.Initialize(connectorsGraphics, thumbnailSize.Width - 1, thumbnailSize.Height - 1, boundingBox, coordinateConverter, connector.Position);
//                connector.AcceptVisitor(thumbnailRender);
//                imageListConnectors.Images.Add(thumbnail);
//                connectorsGraphics.Dispose();
//            }

//            modelComponents.listViewConnectors.LargeImageList = imageListConnectors;
//            modelComponents.listViewConnectors.SmallImageList = imageListConnectors;

//            foreach (Shprosses.Modelling.Components.IComponent shpross in info.Shprosses)
//            {
//                Graphics profilesGraphics;
//                //RectangleF boundingBox = shpross.BoundingBox;
//                //shpross.MoveTo(new Shprosses.Modelling.ModelPoint(boundingBox.Width / 2, boundingBox.Height / 2));
//                shpross.MoveToZeroPoint();
//                RectangleF boundingBox = shpross.BoundingBox;
//                Image thumbnail = new Bitmap(thumbnailSize.Width, thumbnailSize.Height);
//                profilesGraphics = Graphics.FromImage(thumbnail);
//                profilesGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
//                profilesGraphics.Clear(Color.White);
//                thumbnailRender.Initialize(profilesGraphics, thumbnailSize.Width - 1, thumbnailSize.Height - 1, boundingBox, coordinateConverter, shpross.Position);
//                shpross.AcceptVisitor(thumbnailRender);
//                imageListProfiles.Images.Add(thumbnail);
//                profilesGraphics.Dispose();
//            }

//            modelComponents.listViewProfiles.LargeImageList = imageListProfiles;
//            modelComponents.listViewProfiles.SmallImageList = imageListProfiles;

//            for (int connIter = 0; connIter < info.Connectors.Count; connIter++)
//            {
//                modelComponents.listViewConnectors.Items.Add(new ListViewItem(info.Connectors[connIter].Article, connIter));
//            }

//            for (int shprossIter = 0; shprossIter < info.Shprosses.Count; shprossIter++)
//            {
//                modelComponents.listViewProfiles.Items.Add(new ListViewItem(info.Shprosses[shprossIter].Article, shprossIter));
//            }

//            return modelComponents;
//        }

//        private ModelComponents()
//        {
//            InitializeComponent();
//        }
//    }
//}
